#ifndef OBJECTMANAGER_H
#define OBJECTMANAGER_H


#include "database.h"
#include "object.h"
#include "message.h"
#include "networkManager.h"

#include <fstream>
#include <math.h>


/* This class will constantly parse the object array and do the stuff
 * happen in the world, commands what to do will come from the AI class
 * or the network class
 */

class mysql;
class object;   // chicken-egg-problem
class networkManager;   // chicken-egg-problem


using namespace std;


class objectManager {



    public:

        objectManager();
        virtual ~objectManager();


        void Init(void);
        void IntroduceMessage(message *pMsgSystem);
        void IntroduceNetManager(networkManager *pNetManager);
        void IntroduceSQL(mysql *pDataManager);
        long AddObject(object pObject);
        void crossLoop(bool isSecond);
        void crossTask(int source, int target, bool isSecond, bool doGlobal);
        void singleTask(int source);

        // math
        float getDistance(float sourceX, float sourceY, float targetX, float targetY);

        int getCount(void);
        int getCrossTasks(void);

        bool debug;

    protected:


    private:

        int cntCrossTasks;
        int cntBigTasks, configBigTasksSeconds;

        message *msgSystem;
        networkManager *netManager;
        mysql *dataManager;

        fstream logfile;


        vector<object> list;
        int listMAX, listCNT;

        // config
        int configDistanceToCalculate;


};

#endif // OBJECTMANAGER_H
